<?php

	$hash = Jpublic::get('formhash');

	$type = Jpublic::get('type');

	if (JAdmin_core::HASH($hash)) {
		
		$table = PRE . 'detection';
			
		for ($i = 0; $i <= $_POST['detectionListNumber']; $i++) {
			
			$from_data_remove[] = 'detectionListName' . $i;
			
			$from_data_remove[] = 'detectionListType' . $i;
			
			$from_data_remove[] = 'detectionListBasis' . $i;
			
			$from_data_remove[] = 'detectionLisAccording' . $i;
			
			$from_data_remove[] = 'detectionListMode' . $i;
			
			$from_data_remove[] = 'detectionListReason' . $i;
			
			$from_data_remove[] = 'detectionListConclusion' . $i;
			
		}
		
		$from_data_remove[] = 'detectionListNumber';
			
		$form_data = Jdb::data(array(
		
			table => $table,
			
			type => 'POST',
			
			remove => $from_data_remove
		
		));
		
		if ($type == 'insert') {
		
			$form_data['detectionDateTime'] = common::getDate();
			
			$from_data['userID'] = $USER['uid'];
			
			$parentID = Jdb::insert($table, $form_data);
			
			for ($i = 0; $i <= $_POST['detectionListNumber']; $i++) {
				
				$form_list_data = array(
				
					'detectionParentID' => $parentID,
				
					'detectionListName' => Jpublic::post('detectionListName'.$i),
					
					'detectionListType' => implode(',', $_POST['detectionListType'.$i]),
					
					'detectionListBasis' => implode(',', $_POST['detectionListBasis'.$i]),
					
					'detectionLisAccording' => Jpublic::post('detectionLisAccording'.$i),
					
					'detectionListMode' => Jpublic::post('detectionListMode'.$i),
					
					'detectionListReason' => Jpublic::post('detectionListReason'.$i),
					
					'detectionListConclusion' => implode(',', $_POST['detectionListConclusion'.$i]),
				
				);
				
				Jdb::insert($table.'_list', $form_list_data);
				
			}
				
			common::log('insert', '添加检测记录');
			
			$HTML -> tip_html('insert');
		
		} else {
		
			
		
		}
		
	}
	
?>